home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / rayshade / graphtal.lzh / Graphtal.Amiga / Name.h < prev    next >
C/C++ Source or Header  |  1992-11-20  |  2KB  |  75 lines

  1. /*
  2.  * Name.h - class definition for space efficient name storage.
  3.  *
  4.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  5.  *                     University of Berne, Switzerland
  6.  * Portions Copyright (C) 1990, Jonathan P. Leech
  7.  * All rights reserved.
  8.  *
  9.  * This software may be freely copied, modified, and redistributed
  10.  * provided that this copyright notice is preserved on all copies.
  11.  *
  12.  * You may not distribute this software, in whole or in part, as part of
  13.  * any commercial product without the express consent of the authors.
  14.  *
  15.  * There is no warranty or other guarantee of fitness of this software
  16.  * for any purpose.  It is provided solely "as is".
  17.  *
  18.  */
  19.  
  20. #ifndef Name_H
  21. # define Name_H
  22.  
  23. #include <iostream.h>
  24. #include "rcString.h"
  25. #include "list.h"
  26.  
  27. //___________________________________________________________ Name
  28.  
  29. typedef rcString* rcStringPtr;
  30. declareList(rcStringList, rcStringPtr);
  31.  
  32. class Name
  33. {
  34. public:
  35.   Name(const char*);
  36.   Name(const rcString*);
  37.   Name(const Name&);
  38.  
  39.   const Name& operator=(const Name&);
  40.   int operator==(const Name&) const;
  41.   operator const char*() const;
  42.   long index() const;
  43.  
  44.   static long addname(const char*);
  45.   static long namesCount();
  46.   friend ostream& operator<<(ostream&, const Name&);
  47.  
  48. private:
  49.   static rcStringList* GlobalNameSpace;
  50.   long index_;
  51. };
  52.  
  53. typedef Name* NamePtr;
  54. declareList(NameList, NamePtr);
  55.  
  56. inline Name::Name(const Name& aName)
  57. : index_(aName.index_)
  58. {}
  59.  
  60. inline int Name::operator==(const Name& aName) const {
  61.   return (index_ == aName.index_);
  62. }
  63.  
  64. inline long Name::index() const  { 
  65.   return index_; 
  66. }
  67.  
  68. inline long Name::namesCount() { 
  69.   return GlobalNameSpace->count(); 
  70. }
  71.  
  72. #endif // Name_H
  73.  
  74.  
  75.